<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/templates/common/taglib.jsp"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>${title }</title>
    <link rel="stylesheet" href="${basePath}/static/bootstrap/css/bootstrap.css"/>
    <link href="${basePath}/static/css/basic.css" rel="stylesheet" type="text/css">
    <link href="${basePath}/static/css/login.css" rel="stylesheet" type="text/css">
    <link href="${basePath}/static/css/list.css" rel="stylesheet" type="text/css">
    <script  type="text/javascript" src="${basePath}/static/js/jquery.min.js"></script>
	<script  type="text/javascript" src="${basePath}/static/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript" src="${basePath}/static/page/jqPaginator/jqPaginator.js"></script>
	 <script  type="text/javascript" src="${basePath}/static/js/util.js"></script>
    
    <style type="text/css">
    	.btn{
    		padding: 6px;
    	}
    </style>
    
</head>
<body>
<!--头部-->
	<%@include file="/WEB-INF/templates/common/header.jsp"%>
	<!------导航条-->
	<%@include file="/WEB-INF/templates/common/navigation.jsp"%>

<!--内容部分1-->
<div class="list_main lay_out" class="clearfix">
    <div class="list_DH">
        <%@include file="/WEB-INF/templates/common/indexPageAudit.jsp"%>
    </div>
    <div class="list_NR">
        <div class="loc">
            <h3 style="margin:0">人工审核</h3>
        </div>
        <div class="list_con_table">
            <div class="search_table">
                <ul class="clearfix" style="margin-bottom:0;">
    <li class="Label_1" style="width:10%">识别码：&nbsp;</li>
    <li class="Label_2" style="width:23%"><input class="input_box" type="text" id="mrId" /></li>
    <li class="Label_1" style="width:10%">身份证：&nbsp;</li>
    <li class="Label_2" style="width:23%"><input class="input_box" type="text" id="idCard"/></li>
    <li class="Label_1" style="width:10%">姓名：&nbsp;</li>
    <li class="Label_2" style="width:23%"><input class="input_box" type="text" id="name"/></li>
    <li class="Label_1" style="width:10%">离院方式：&nbsp;</li>
    <li class="Label_3" style="width:89%" id="outHosType">

    </li>
     <li class="Label_1" style="width:10%">出院日期：&nbsp;</li>
    <li class="Label_2" style="text-align:left;padding-left:3px;width:33%">
           <input class="input_box" style="width:43%;" type="text" id='outHospitalStartDate' onFocus="WdatePicker()" />
           <span>&nbsp;-&nbsp;</span>
           <input class="input_box" type="text" style="width:43%;" id='outHospitalEndDate' onFocus="WdatePicker()" />
    </li>
    <li class="Label_1" style="width:10%">出院科室：&nbsp;</li>
    <li class="Label_2">
    	<select class="input_box" id="outHospitalOfficeId">
    	
    		<option value="">请选择</option>
    		
    	</select>
    </li>
    <li class="Label_5">
     <a onclick="searchQua()">查询</a>
    </li>
    </ul>
   </div>
   <table class="Search_tableList" cellpadding="0" cellspacing="0">
      <tr>
      <td class="tdLabel_4">识别码</td>
      <td class="tdLabel_4">姓名</td>
      <td class="tdLabel_4">出院时间</td>
       <td class="tdLabel_4">出院科室</td>
       <td class="tdLabel_4">出院方式</td>
       <td class="tdLabel_4">身份证号</td>
      <td class="tdLabel_4">操作</td>
      </tr>
      <tbody id="tbody">

      	
      </tbody>
   </table>
   <input type="hidden" value="0" id="totalCountHidden"/>
   <input type="hidden" value="0" id="pageNoHidden"/>
        </div>
        	   <div class="pageList">
		            <ul class="pagination clearfix" id="page_plus"></ul>
		            <div class="pagination">
		                <div>总共：<b id="totalPage">0</b> 条信息    当前页是第 <b id="currentPage">0/0</b>　页</div>
		            </div>
       		  </div>
         
    </div>
</div>
<!------页脚部分--------->
<%@include file="/WEB-INF/templates/common/footer.jsp"%>

<!--JS部分-->
<script type="text/javascript">

$(function(){
	queryQua(1,1);
	getManualReviewBasicDataAjax();
	
});

function getManualReviewBasicDataAjax(){
	$.ajax({
		type : "post",
		url : "${corePath}/medrecord/getManualReviewBasicDataAjax",
		success : function(data) {
            if(data.success){
            	var basicData = data.data;
            	var offices = basicData.offices;
            	var outHosTypes = basicData.outHosTypes;
            	var html1 = "";
            	if(outHosTypes!=null && outHosTypes.length>0){
            		for (var i = 0; i < outHosTypes.length; i++) {
						var obj = outHosTypes[i];
						html1 = html1+"<input type='checkbox' class='check_cl'"
						+"name='outHosTypeId' value='"+obj.id+"'/>"+obj.name;
					}
            		$("#outHosType").append(html1);
            	}
            	
            	var html2 = "";
            	if(offices!=null && offices.length>0){
            		for (var i = 0; i < offices.length; i++) {
						var obj = offices[i];
						html2 = html2+"<option value='"+obj.id+"'>"+obj.name+"</option>"
					}
            		$("#outHospitalOfficeId").append(html2);
            	}
				
            }else{
            	alert("查询失败");
            }
		}
	});
}
	
	function searchQua() {
		queryQua(1,1);
	}

	function queryQua(pageNo, pageSize) {
		var startDate = $("#outHospitalStartDate").val();
		var endDate = $("#outHospitalEndDate").val();
		var name = $("#name").val();
		var mrId = $("#mrId").val();
		var idCard = $("#idCard").val();
		var outDeptId = $("#outHospitalOfficeId").val();
		var ids = getFormVals("outHosTypeId");
		$.ajax({
					type : "post",
					url : "${corePath}/medrecord/manualReviewAjax",
					data : {
						outHospitalStartDate : startDate,
						outHospitalEndDate : endDate,
						name : name,
						mrId : mrId,
						idCard : idCard,
						outHospitalOfficeId : outDeptId,
						outHosTypeIds:ids,
						currentPage : pageNo,
						pageSize : pageSize
					},
					success : function(data) {
						$("#tbody").html("");
						$("#totalPage").html(0);
			            $("#currentPage").html(0+"/"+0);
			            $('#page_plus').html("");
			            
			            if(data.success){
			            	var quaList = data.data.auditList;
							if (quaList != null && quaList.length!=0) {
								var count = data.data.count;
								$("#totalCountHidden").val(count);
		    					$("#pageNoHidden").val(pageNo);
								var html = "";
								for (var i = 0; i < quaList.length; i++) {
									var obj = quaList[i];
									html += "<tr>" + "  <td class='tdLabel_5'>"
											+ obj.mr_id
											+ "</td>"
											+ "  <td class='tdLabel_5'>"
											+ obj.name
											+ "</td>"
											+ "  <td class='tdLabel_5'>"
											+ obj.out_hospital_date
											+ "</td>"
											+ "  <td class='tdLabel_5'>"
											+ obj.outOfficeName
											+ "</td>"
											+ "  <td class='tdLabel_5'>"
											+ obj.outHospitalTypeName
											+ "</td><td class='tdLabel_5' style='width:18%'>"
											+ obj.id_number
											+ "</td><td class='tdLabel_5' style='width:20%'>"
											+"<a onclick=\"homePage('"+obj.first_level_medical_guid+"')\">首页编辑</a>&nbsp;&nbsp;"
							      			+"<a onclick=\"showMedRedcordImage('"+obj.first_level_medical_guid+"')\">图片预览</a>&nbsp;&nbsp;"
							      			+"<a onclick=\"audit("+i+",'"+obj.first_level_medical_guid+"')\">审核</a>"
											+ "</td></tr>";

								}

								$("#tbody").html(html);
								page(pageNo, count,pageSize);
							} 
			            }else{
			            	alert("查询失败");
			            }
					}
				});

	}

	function page(currentPage, totalCounts,pageSize) {
		if(pageSize==null || pageSize=="" || pageSize==0){
	        pageSize = 10;
	    }
		var visiblePages = 5;
		/* var totalPages = totalCounts%pageSize==0?(totalCounts/pageSize):(totalCounts/pageSize+1); */
		var totalPages = Math.ceil(totalCounts / pageSize);
		$('#page_plus')
				.jqPaginator(
						{

							totalCounts : totalCounts,
							pageSize : pageSize,
							visiblePages : visiblePages,
							currentPage : currentPage,

							first : '<li class="first"><a href="javascript:void(0);">首页</a></li>',
							prev : '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
							next : '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
							last : '<li class="last"><a href="javascript:void(0);">末页</a></li>',
							page : '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
							onPageChange : function(num, type) {

								if (type != 'init') {

									queryQua(num, pageSize);
								}

								$("#totalPage").html(totalCounts);
								$("#currentPage").html(num + "/" + totalPages);
							}
						});

	}
	
	function homePage(guid){
		window.open("${corePath}/medrecord/medrecordHomePageManage?firstGuid="+guid);
	}
	
	function showMedRedcordImage(guid){
		window.open("${corePath}/medrecord/showMedrecordImage?firstGuid="+guid);
	}
	
	function audit(i,guid){
		var td = $("#tbody").find("td");
		var mrId = td.eq(0).text();
		var name = td.eq(1).text();
		var outHospitalDate = td.eq(2).text();
		var outOfficeName = td.eq(3).text();
		var	idCard = td.eq(5).text();
			
		window.open("${scanPath}/quality/detailControl?uniqueKey="+guid+"&name="+name
				+"&mrId="+mrId+"&outHospitalDate="+outHospitalDate+"&outOfficeName="+outOfficeName+"&idCard="+idCard);
	}
	
</script>

</body>
</html>